class ScoreManager{
    constructor(){
        this.score = 0;
    }
    update(){

    }
    render(){
        let numLength = this.score.toString().length;
        // console.log(numLength);
        let beginX = 0;
        //判断位数是奇数还是偶数
        if((numLength & 1) === 0){
            //偶数
            beginX = game.canvas.width / 2 - numLength / 2 * 48;
            // console.log(beginX);
        }else if((numLength & 1) === 1){
            //奇数
            beginX = game.canvas.width / 2 - numLength / 2 * 48;
        }


        for(let i = 0; i < numLength; ++i){
            let curNum = parseInt(this.score.toString().substr(i,1));
            this.renderOneScore(curNum, beginX + i * 48, 100)
        }



    }
    renderOneScore(score, x, y){
        // game.pen.drawImage(game.images.score,this.score*48,0,38,50,game.canvas.width/2-20,game.canvas.height/2-20,45,50)
        game.pen.drawImage(game.images.score,score*48,0,38,50,x,y,45,50)
    }
}   